import React from 'react';
import {withRouter, Redirect} from 'react-router-dom';
import {inject, observer} from 'mobx-react';
// ui
import RegisterForm from './Ui/RegisterForm/RegisterForm';
import '../css/pages/Login.css';


@inject ('store')
@withRouter
@observer
export default class Register extends React.Component {
  render () {
    // const self = this;
    const {login} = this.props.store.loginStatus;
    let from = {pathname: '/home'};
    if (this.props.location.state && this.props.location.state.from) {
      from = {pathname:this.props.location.state.from};
    }
    // 没有登录
    if (login) {
      return <Redirect to={from} />;
    }
    return (
      <RegisterForm />
    );
  }
}

